*===============================================================================*
*																				*
*		THIS DO FILE PRODUCES ONLINE APPENDIX TABLE A1 							*
* 		IN LONDONO-VELEZ AND QUERUBIN											*
*		"THE IMPACT OF EMERGENCY CASH ASSISTANCE IN A PANDEMIC: EXPERIMENTAL 	* 
* 		EVIDENCE FROM COLOMBIA", REVIEW OF ECONOMICS AND STATISTICS				*
*																				*
*		LAST MODIFIED: 2021-02-02												*
*																				*
*===============================================================================*

	use 	"${datadir}/balance.dta", clear
	
	global 	controls "Complete Incomplete Rejected Unreachable fea_hog_DPS_data cm MPM cod_urban sisben4 sisben3 Female age_01apr2020 estadocivil_1 estadocivil_2 estadocivil_3 estadocivil_4 estadocivil_5 victim dem4 edu0 inc sector_1 sector_2 sector_3 sector_4 sector_5 sector_6 sector_7 sector_8 sector_9 sector_10 sector_11 sector_12 sector_13 sector_14"
		
	cap 	drop one
	gen 	one = 1
	glo 	ncontrols = 35
	local 	rows = $ncontrols+2
	matrix 	results = J(`rows',4,.)
	matrix 	rown results = $controls
	
	local oo = 0
	foreach o in $controls{	
		local l`o' : variable label `o'
				if `"`l`o''"' == "" {
					local l`o' "`o'"
					}
		local tt = 0
		foreach t of numlist 0 1{		
		qui: sum `o' if treated == `t'
		matrix results[1+`oo',`tt'+1]=round(r(mean), .001)
		local tt = `tt'+1
		}
	qui: reg `o' treated, r	
	matrix results[1+`oo',3]=round((2 * ttail(e(df_r), abs(_b[treated]/_se[treated]))), .001)
	matrix results[1+`oo',4]=e(N)	
	local oo = `oo'+1
		}
	local tt = 0
	foreach t of numlist 0 1{		
		qui: sum one if treated == `t'
		matrix results[`rows',`tt'+1]=r(N)
		local tt = `tt'+1
		}
	qui: sum one 	
	matrix results[`rows',4]=r(N)	
	matrix list results
	svmat results
	keep results*
	drop if _n>`rows'
	rename results1 Control
	rename results2 Treatment
	rename results3 pvalue
	rename results4 N
	gen 	variable = ""
	local oo = 1
	foreach o in $controls{	
	replace variable = "`l`o''" in `oo'
	local oo = `oo'+1
	}
	replace variable = "N" in `rows'
	order 	variable Control Treatment pval N
	format 	Control Treatment pval %5.3f
	export 	excel using "OnlineAppendix/TA1", sheet("TA1") sheetmod firstrow(variables)
	
